<%@ page import = "clothing.database.SupplierManager" %>
<%@ page import = "clothing.database.Supplier" %>
<%@ page import = "java.util.ArrayList" %>
<%@ include file = "templates/header.jsp" %>

<h3> Supplier Page </h3>
<script>
function process(a)
{
	var con = confirm("Are you sure you want to delete this supplier?");
	if(con==true)
	{
		document.getElementById('id').value=a;
		document.myform.submit();
	}
}  
function process2 (a)
{
	document.getElementById('id2').value=a;
	document.myform2.submit();	
	
}
</script>
<%@ include file="templates/main_nav.jsp" %>
<%
	SupplierManager sm = new SupplierManager();
	ArrayList<Supplier> list = sm.getList();
	
	out.println("<form name =\"myform\" id=\"myform\" action =\"deleteSupplier.jsp\" method=\"post\">");
	out.println("<table>");
	%>
	<tr>
		<td><strong>ID</strong></td>
		<td><strong>Name</strong></td>
		<td><strong>Contact Number</strong></td>
		<td><strong>Street</strong></td>
		<td><strong>City</strong></td>
		<td><strong>State</strong></td>
		<td><strong>Zip</strong></td>		
	</tr>
	<input type="hidden" name ="id" id = "id" />
	
	<% 
	
	for(int i=0;i<list.size();i++)
	{
		out.println("<tr>");
		Supplier current = list.get(i);
			out.println("<td>"+ current.getId()+"</td>");
			out.println("<td>"+ current.getName()+"</td>");
			out.println("<td>"+ current.getContactNumber()+"</td>");
			out.println("<td>"+ current.getStreet()+"</td>");
			out.println("<td>"+ current.getCity()+"</td>");
			out.println("<td>"+ current.getState()+"</td>");
			out.println("<td>"+ current.getZip()+"</td>");
			
			%>
		
			<td><input type="button" value ="Delete" onclick = "process(<%=current.getId() %>);" /></td>
			<td><input type="button" value ="Edit" onclick = "process2(<%=current.getId() %>);" /></td>
			<% 
		out.println("</tr>");
	}
	

	out.println("</table></form>");
	
	
%>
<form name="myform2" id="myform2" action="editSupplier.jsp" method="post"></form>
<input type="hidden" name="id2" id="id2" />
<h2> Add a Supplier </h2>
<form action ="addSupplier.jsp" method = "post" >
	<table>
		<tr>
			<td>Name: </td><td><input type="text" name="name" /></td>
		</tr>

		<tr>
			<td>Contact Number : </td><td><input type="text" name="contactnum" /></td>
		</tr>

		<tr>
			<td>Street: </td><td><input type="text" name="street" /></td>
		</tr>

		<tr>
			<td>City: </td><td><input type="text" name="city" /></td>
		</tr>

		<tr>
			<td> State: </td>
         	<td>
			<select name="state" size="1">
	<option value="AK">AK</option>
	<option value="AL">AL</option>
	<option value="AR">AR</option>
	<option value="AZ">AZ</option>
	<option value="CA">CA</option>
	<option value="CO">CO</option>
	<option value="CT">CT</option>
	<option value="DC">DC</option>
	<option value="DE">DE</option>
	<option value="FL">FL</option>
	<option value="GA">GA</option>
	<option value="HI">HI</option>
	<option value="IA">IA</option>
	<option value="ID">ID</option>
	<option value="IL">IL</option>
	<option value="IN">IN</option>
	<option value="KS">KS</option>
	<option value="KY">KY</option>
	<option value="LA">LA</option>
	<option value="MA">MA</option>
	<option value="MD">MD</option>
	<option value="ME">ME</option>
	<option value="MI">MI</option>
	<option value="MN">MN</option>
	<option value="MO">MO</option>
	<option value="MS">MS</option>
	<option value="MT">MT</option>
	<option value="NC">NC</option>
	<option value="ND">ND</option>
	<option value="NE">NE</option>
	<option value="NH">NH</option>
	<option value="NJ">NJ</option>
	<option value="NM">NM</option>
	<option value="NV">NV</option>
	<option value="NY">NY</option>
	<option value="OH">OH</option>
	<option value="OK">OK</option>
	<option value="OR">OR</option>
	<option value="PA">PA</option>
	<option value="RI">RI</option>
	<option value="SC">SC</option>
	<option value="SD">SD</option>
	<option value="TN">TN</option>
	<option value="TX">TX</option>
	<option value="UT">UT</option>
	<option value="VA">VA</option>
	<option value="VT">VT</option>
	<option value="WA">WA</option>
	<option value="WI">WI</option>
	<option value="WV">WV</option>
	<option value="WY">WY</option>
</select>
</td>
		</tr>

		<tr>
			<td>Zip: </td><td><input type="text" size="5" name="zip" /></td>
		</tr>

		
		<tr>
			<td> </td><td><input type="submit" value= "submit" /></td>
		</tr>
	</table>
	</form>

<%@ include file = "templates/footer.jsp" %>
